﻿#region Usings

using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;


#endregion

namespace ScrumTable.UI.View.WinTouch.UserControls.Tool.Toast
{
    /// <summary>
    /// BaseToastControl
    /// </summary>
    public class BaseToastControl : ScrumUserControl
    {

        #region Declarations
        //--------------------------------------------------------------------
        // Declarations
        //--------------------------------------------------------------------
     
        #endregion

        #region Properties
        //--------------------------------------------------------------------
        // Properties
        //--------------------------------------------------------------------
     
        #endregion

        #region Constructors / Destructor
        //--------------------------------------------------------------------
        // Constructors / Destructor
        //--------------------------------------------------------------------
      
        #endregion




        #region Methods

        private static void ShowHideItem(object sender)
        {
            var control = ((FrameworkElement)sender).FindName("AffectedItems") as FrameworkElement;
            var row = ((FrameworkElement)sender).FindName("FirstRow") as RowDefinition;


            if (control != null)
            {
                control.Visibility = control.Visibility != Visibility.Visible ? Visibility.Visible : Visibility.Collapsed;
                if (row != null)
                {
                    row.Height = control.Visibility == Visibility.Visible ? new GridLength(0, GridUnitType.Auto) : new GridLength(row.MinHeight, GridUnitType.Pixel);
                }
            }
        }

        #endregion


        #region Events



        protected void OnItemMouseDown(object sender, MouseButtonEventArgs e)
        {
            ShowHideItem(sender);
            e.Handled = true;
        }



        protected void OnItemTouchDown(object sender, TouchEventArgs e)
        {
            ShowHideItem(sender);
            e.Handled = true;
        }

        #endregion
    }
}
